﻿Imports System.Net
Imports System.Xml

Public Class SOAPmanager
    ''' <summary>
    ''' Sends SOAP to a web service and sends back the XML it got back.
    ''' </summary>



    Public Shared Function CallWebService(ByVal WebserviceURL As String, ByVal SOAP As String) As XmlDocument
        Using wc As New WebClient()
            Dim retXMLDoc As New XmlDocument()

            ' wc.Headers.Add("Content-Type", "application/soap+xml; charset=utf-8")
            wc.Headers.Add("Content-Type", "text/xml")
            'In the request header, the Content‐Type should be set to “text/xml”, and the SOAPAction
            'should be set to “urn:MobileWorks#METHODNAME”, where METHODNAME is the method
            'you are attempting to call.

            wc.Headers.Add("SOAPAction", "urn:MobileWorks#apiValidateLogin")
            retXMLDoc.LoadXml(wc.UploadString(WebserviceURL, SOAP))
            '  retXMLDoc.LoadXml(wc.UploadString(WebserviceURL,)

            Return retXMLDoc
        End Using
    End Function



    Private Function FirstCallWebService(ByVal WebserviceURL As String, ByVal SOAP As String) As XmlDocument



        Return Nothing
    End Function



End Class
